import path  from 'path';
import jwt  from 'jsonwebtoken';


export default class Jwt {

   

    //生成token
    public static  generateToken(data:string|undefined) {

        let jwtdata = {
        "jti": 1,
        "iss": "think-admin",
        "name":data}
       return jwt.sign(jwtdata,'tokenkey', {
            expiresIn: 1000*60*60*24*1 
        });

    }

    // 校验token
    public static verifyToken(token:string):boolean {
    let verifystatus  = 1
     jwt.verify(token,'tokenkey' , function (err:any) {
            if (err) verifystatus = 0
            })

    if(verifystatus == 0){
        return false
    }else{
        return true
    }
            }
          
    }

